package FileMangerClient;



import Controllers.Context;
import DiskManager.Disk;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.FlowPane;

public class DiskUsageUIController {

	@FXML
    private FlowPane flowPane;
    
    public DiskUsageUIController() {
    	 Context.controllers.put(this.getClass().getSimpleName(), this);
    }
     
    public void update(Disk disk) {
    	flowPane.getChildren().clear();
    	for(int i=0;i<256;i++)
    	{
    		switch (disk.getFAT()[i]) {
			case 257:
				Button button = new Button(Integer.toString(i));
				button.setPrefHeight(50);
				button.setPrefWidth(50);
				button.setStyle("-fx-background-color:#ddc50c");
				flowPane.getChildren().add(button);
				break;
			case 0:
				Button button1 = new Button(Integer.toString(i));
				button1.setPrefHeight(50);
				button1.setPrefWidth(50);
				button1.setStyle("-fx-background-color:#41e01e");
				flowPane.getChildren().add(button1);
				break;
			
			default:
				Button button2 = new Button(Integer.toString(i));
				button2.setPrefHeight(50);
				button2.setPrefWidth(50);
				button2.setStyle("-fx-background-color:#dd3838");
				flowPane.getChildren().add(button2);
				break;
			}
    	}
    	
    }
    
}